package time;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Demo01 {

    public static void main(String[] args) {
        long time = System.currentTimeMillis();
        System.out.println(time);

        Date date = new Date(time);
        System.out.println("毫秒转日期"+date);
        System.out.println("日期转毫秒"+date.getTime());


        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:dd:SS");
        String s = dateFormat.format(date);
        System.out.println("日期转字符串"+s);
        try {
            System.out.println("字符串转日期"+dateFormat.parse(s));
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


    }
}
